#include <ctype.h>
#include <string.h>
#include <stdio.h>

char * itoh(int v, char * b)
{
    char buf[6];
    char * map = "0123456789ABCDEF";
    int i = 8;

    buf[i+1] = 0;

    if (v == 0)
        {
        buf[i--] = '0';
        }

    while (i != 0)
        {
        buf[i--] = map[(v & 0xf)];
        v =v >> 4;
        }

    strcpy(b, &buf[i+1]);

    return b;
}

char * itoa(int v, char * b)
{
    char buf[12];
    int f = 0;
    int i = 10;

    buf[i+1] = 0;

    if (v < 0)
        f = 1, v = -v;

    if (v == 0)
        {
        buf[i--] = '0';
        }

    while (v > 0)
        {
        buf[i--] = (v % 10) + '0';
        v = v / 10;
        }

    if (f == 1)
        {
        buf[i--] = '-';
        }

    strcpy(b, &buf[i+1]);

    return b;
}

int isalpha(int c)
{
    if (islower(c) || isupper(c))
        return 1;

    return 0;
}

int isalnum(int c)
{
    if (isalpha(c) || isdigit(c))
        return 1;

    return 0;

}

int isdigit(int c)
{
    if (c >= '0' && c <= '9')
        return 1;

    return 0;
}


int islower(int c)
{
    if (c >= 'a' && c <= 'z')
        return 1;

    return 0;

}
int isupper(int c)
{
    if (c >= 'A' && c <= 'Z')
        return 1;

    return 0;
}

int tolower(int c)
{
    if (!isalpha(c))
        return c;

    if (islower(c))
        return c;

    c = c + ('a' - 'A');

    return c;
}

int toupper(int c)
{
    if (!isalpha(c))
        return c;

    if (isupper(c))
        return c;

    c = c - ('a' - 'A');

    return c;
}

